﻿using System;
using System.Collections.Generic;
using GCTrackableRace.Interfaces;
using System.IO;

namespace GcTrackableRace.Entities
{
	public class ProgramConfigurationSettings: IProgramConfigurationSettings
	{
		private DateTime _CurrentDate = DateTime.Now;

		public string TrackableRaceName { get; set; }
		public string OutputDirectory { get; set; }

		public string GeocacheDatabaseNameAndLocation { get; set; }
		public string TrackablesDatabaseNameAndLocation { get; set; }
		public string GcTrackableRaceDatabaseNameAndLocation { get; set; }

		public List<List<Tuple<string, string>>> RaceRuleParameters { get; set; }

		public IEnumerable<string> OutputFormats { get; set; }

		public string GetOutputFileNameAndLocation(FileType fileType)
		{
			var fileName = String.Format("{0} ({1}-{2}-{3} {4}H{5}) - {6}.{7}",
				TrackableRaceName,
				_CurrentDate.Year,
				_CurrentDate.Month,
				_CurrentDate.Day,
				_CurrentDate.Hour,
				_CurrentDate.Minute,
				fileType == FileType.CsvRaceResultTextFile ? "Race Results" :
				fileType == FileType.TabRaceResultTextFile ? "Race Results" :
				fileType == FileType.TabScoreAtEndRaceResultTextFile ? "Race Results" :
				fileType == FileType.JsonRaceResultTextFile? "Race Results" :
				fileType == FileType.MissingInfoLogFile ? "Missing Info" :
				fileType == FileType.TextLogFile ? "Race Logs" :
				"Unknown",
				fileType == FileType.CsvRaceResultTextFile ? "txt.csv" :
				fileType == FileType.JsonRaceResultTextFile ? "json.txt" :
				fileType == FileType.TabRaceResultTextFile ? "tab.txt" :
				fileType == FileType.TabScoreAtEndRaceResultTextFile ? "tabScore.txt" :
				fileType == FileType.MissingInfoLogFile ? "txt" :
				fileType == FileType.TextLogFile ? "txt" :
				"Unknown"
			);

			return Path.Combine(OutputDirectory, fileName);
		}
	}
}
